package com.org.gsc.chartdemo.activitys;

import android.graphics.Color;

import com.github.mikephil.charting.charts.ScatterChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.ScatterData;
import com.github.mikephil.charting.data.ScatterDataSet;
import com.github.mikephil.charting.interfaces.datasets.IScatterDataSet;
import com.org.gsc.chartdemo.R;
import com.org.gsc.chartdemo.bases.BaseActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by qundui on 2017/8/30.
 */
// 散点图
public class ScatterActivity extends BaseActivity {
    private ScatterChart mScatterChart;
    private List<IScatterDataSet> mdatas;
    private ScatterData mScatterData;
    private ScatterDataSet m散点图;

    @Override
    protected void doBusy() {
        mScatterChart=findView(R.id.chart1);
        mdatas=new ArrayList<>();
        List<Entry> yvales=new ArrayList<>();
        yvales.add(new Entry(0.2f,0.4f));
        yvales.add(new Entry(0.3f,0.5f));
        yvales.add(new Entry(0.8f,0.7f));
        yvales.add(new Entry(0.6f,0.4f));
        yvales.add(new Entry(0.7f,0.4f));
        yvales.add(new Entry(0.8f,2.4f));
        yvales.add(new Entry(1.2f,3.4f));
        yvales.add(new Entry(3.2f,0.45f));
        yvales.add(new Entry(0.25f,0.48f));
        yvales.add(new Entry(4.0f,6.0f));
        m散点图 = new ScatterDataSet(yvales, "散点图");
        m散点图.setColor(Color.RED);
        m散点图.setValueTextSize(15f);
        mdatas.add(m散点图);
        mScatterChart.getDescription().setEnabled(false);
        mScatterData = new ScatterData(mdatas);
        mScatterData.setValueTextColor(Color.GREEN);
        Legend legend = mScatterChart.getLegend();
        legend.setTextSize(34f);
        legend.setTextColor(Color.RED);
        mScatterChart.getAxisLeft().setEnabled(false);
        mScatterChart.getAxisRight().setEnabled(false);
         mScatterChart.getXAxis().setDrawGridLines(false);
        mScatterChart.getXAxis().setEnabled(false);
        mScatterChart.setData(mScatterData);

    }
    @Override
    protected int getLayoutId() {
        return R.layout.sandianpic;
    }
}
